package br.com.vti.sisp_sicrim.controller;

import org.springframework.beans.factory.annotation.Qualifier;

import br.com.caelum.vraptor.Get;
import br.com.caelum.vraptor.Path;
import br.com.caelum.vraptor.Resource;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.Validator;
import br.com.crud4j.core.model.business.Business;
import br.com.crud4j.core.util.MessageResolver;
import br.com.crud4j.vraptor3.controller.ControllerImpl;
import br.com.vti.sisp_sicrim.model.entity.Delegacia;
import br.com.vti.sisp_sicrim.model.entity.Estado;
import br.com.vti.sisp_sicrim.model.entity.Municipio;
import br.com.vti.sisp_sicrim.modelo.business.exception.DelegaciaException;
import br.com.vti.sisp_sicrim.modelo.business.exception.EstadoException;
import br.com.vti.sisp_sicrim.modelo.business.exception.MunicipioException;

@Resource
@Path("/pages/delegacia")
public class DelegaciaController extends ControllerImpl<Delegacia, DelegaciaException> {
	
	private final Business<Estado, EstadoException> estadoBusiness;

	public DelegaciaController(Result result, Validator validator,
			@Qualifier("delegaciaBusiness") Business<Delegacia, DelegaciaException> entidadeBusiness,
			@Qualifier("estadoBusiness") Business<Estado, EstadoException> estadoBusiness,
			MessageResolver messageResolver) {
		super(result, validator, entidadeBusiness, messageResolver);
		this.estadoBusiness = estadoBusiness;
	}
    
    @Override
    @Get(value={"novo","buscar/{entidade.id}"})
    public void cadastrar(Delegacia entidade) {
    	include("estadoList", estadoBusiness.listar(null));
    	super.cadastrar(entidade);
    }
    
}
